//
//  OderSectionHeaderView.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/9/22.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "OderSectionHeaderView.h"

@interface OderSectionHeaderView ()
//订单编号
@property (nonatomic,weak) UILabel *orderTitleLabel;


@property(nonatomic,strong)UIView * underLine;

@property(nonatomic,strong)UIImageView * backgroundImage;
@end
@implementation OderSectionHeaderView


-(id)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        UILabel *orderTitleLabel = [[UILabel alloc] init];
        orderTitleLabel.textAlignment = NSTextAlignmentRight;
        orderTitleLabel.text = @"订单编号:";
        orderTitleLabel.font = [UIFont systemFontOfSize:15];
        
        //        orderTitleLabel.backgroundColor = [UIColor redColor];
        
        [self addSubview:orderTitleLabel];
        self.orderTitleLabel = orderTitleLabel;
        
        UILabel *orderNumberLabel = [[UILabel alloc] init];
        orderNumberLabel.textAlignment = NSTextAlignmentLeft;
        //        orderNumberLabel.text = @"0000001";
        orderNumberLabel.font = [UIFont systemFontOfSize:15];
        
        //        orderNumberLabel.backgroundColor = [UIColor blueColor];
        
        [self addSubview:orderNumberLabel];
        self.orderNumberLabel = orderNumberLabel;
        
        UILabel *orderStatusLabel = [[UILabel alloc] init];
        orderStatusLabel.textAlignment = NSTextAlignmentCenter;
        orderStatusLabel.text = @"待收货";
        orderStatusLabel.font = [UIFont systemFontOfSize:15];
        
        //        orderStatusLabel.backgroundColor = [UIColor yellowColor];
        
        [self addSubview:orderStatusLabel];
        self.orderStatusLabel = orderStatusLabel;
        
        UIView * v = [[UIView alloc] initWithFrame:CGRectZero];
        v.backgroundColor = HexColor(@"#EEEEEE");
        [self addSubview:v];
        self.underLine = v;
        
        UIImageView * imgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"brokerage_bg02"]];
        imgv.transform = CGAffineTransformRotate(imgv.transform, M_PI);
        [self insertSubview:imgv atIndex:0];
        self.backgroundImage = imgv;
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.orderTitleLabel.size = [self.orderTitleLabel.text sizeInAre:MaxSize font:self.orderTitleLabel.font];
    self.orderTitleLabel.x = 2*globalMargin;
    self.orderTitleLabel.centerY = self.height  * 0.5;
    
    
    self.orderNumberLabel.size = [self.orderNumberLabel.text sizeInAre:MaxSize font:self.orderNumberLabel.font];
    self.orderNumberLabel.x = self.orderTitleLabel.right + globalMargin;
    self.orderNumberLabel.centerY = self.orderTitleLabel.centerY;
    
    self.orderStatusLabel.size = [self.orderStatusLabel.text sizeInAre:MaxSize font:self.orderStatusLabel.font];
    self.orderStatusLabel.x = self.width - self.orderStatusLabel.width - 2*globalMargin;
    self.orderStatusLabel.centerY = self.orderNumberLabel.centerY;
    
    self.underLine.width = self.width - 4*globalMargin;
    self.underLine.x = 2*globalMargin;
    self.underLine.height = 0.5;
    self.underLine.y = self.height - 1;
    
    self.backgroundImage.width = self.width-2*globalMargin;
    self.backgroundImage.height = self.height;
    self.backgroundImage.x = globalMargin;
    self.backgroundImage.y = 0;
}

@end
